summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2022-12-25 19:20:59 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2022-12-25 19:20:59 +0100
commit9349f06963759705f69bd3a23a4df5354bbf6951 (patch)
tree80ee8f85fdd6df343c145951d88d282895ce364c
parentMerge pull request #9500 from liamwhite/reentrant-shutdown (diff)
downloadyuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar.gz
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar.bz2
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar.lz
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar.xz
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.tar.zst
yuzu-9349f06963759705f69bd3a23a4df5354bbf6951.zip
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp19
-rw-r--r--src/core/hle/kernel/hle_ipc.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 738b6d0f1..549fd8aea 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -345,6 +345,25 @@ std::vector<u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const {
}
}
+std::span<const u8> HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const {
+ LOG_CRITICAL(Debug, "called");
+ const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
+ BufferDescriptorA()[buffer_index].Size()};
+ if (is_buffer_a) {
+ ASSERT_OR_EXECUTE_MSG(
+ BufferDescriptorA().size() > buffer_index, { return {}; },
+ "BufferDescriptorA invalid buffer_index {}", buffer_index);
+ const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address());
+ return std::span<const u8>(mem_ptr, BufferDescriptorA()[buffer_index].Size());
+ } else {
+ ASSERT_OR_EXECUTE_MSG(
+ BufferDescriptorX().size() > buffer_index, { return {}; },
+ "BufferDescriptorX invalid buffer_index {}", buffer_index);
+ const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address());
+ return std::span<const u8>(mem_ptr, BufferDescriptorX()[buffer_index].Size());
+ }
+}
+
std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size,
std::size_t buffer_index) const {
if (size == 0) {
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index e252b5f4b..2242ff922 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -7,6 +7,7 @@
#include <functional>
#include <memory>
#include <optional>
+#include <span>
#include <string>
#include <type_traits>
#include <vector>
@@ -273,6 +274,8 @@ public:
/// Helper function to read a buffer using the appropriate buffer descriptor
[[nodiscard]] std::vector<u8> ReadBuffer(std::size_t buffer_index = 0) const;
+ [[nodiscard]] std::span<const u8> ReadBufferSpan(std::size_t buffer_index = 0) const;
+
/// Helper function to write a buffer using the appropriate buffer descriptor
std::size_t WriteBuffer(const void* buffer, std::size_t size,
std::size_t buffer_index = 0) const;